//
//  DDCommonDataService.m
//  DingDongZP
//
//  Created by Jyh on 16/4/26.
//  Copyright © 2016年 iyhjiang.com. All rights reserved.
//

#import "DDCommonDataService.h"
#import "DDCommonDataModel.h"

@implementation DDCommonDataService

- (void)queryAllProvinceInfoSuccessBlock:(successBlock)successBlock
                               failBlock:(faileBlock)failBlock
{
    NSString *URLString = [[DDAPIGenerate sharedInstance] API:@"common_provinces"];
    
    NSMutableDictionary *params = [@{} mutableCopy];
    
    DDNetWorkManager *manager = [DDNetWorkManager shareManager];
    
    [manager GET:URLString parameters:params success:successBlock failure:failBlock];
}

- (void)queryAllProviceInfo:(void (^)(NSArray *provices))callback
{
    NSString *URLString = [[DDAPIGenerate sharedInstance] API:@"common_cities"];
    
    NSMutableDictionary *params = [@{} mutableCopy];
    
    DDNetWorkManager *manager = [DDNetWorkManager shareManager];

    [manager GET:URLString parameters:params success:^(id responseObject) {
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 1) {
            NSArray *datas = responseObject[@"data"];
            NSArray *models = [NSArray yy_modelArrayWithClass:[DDCommonDataModel class] json:datas];
            callback(models);
        }
        else {
            callback(nil);
        }
    } failure:^(id responseObject, NSError *error) {
        callback(nil);
    }];
}

- (void)queryAllSalariesInfo:(void (^)(NSArray *salaries))callback
{
    NSString *URLString = [[DDAPIGenerate sharedInstance] API:@"common_salary"];
    
    NSMutableDictionary *params = [@{} mutableCopy];
    
    DDNetWorkManager *manager = [DDNetWorkManager shareManager];
    
    [manager GET:URLString parameters:params success:^(id responseObject) {
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 1) {
            NSArray *datas = responseObject[@"data"];
            NSArray *models = [NSArray yy_modelArrayWithClass:[DDCommonDataModel class] json:datas];
            callback(models);
        }
        else {
            callback(nil);
        }
    } failure:^(id responseObject, NSError *error) {
        callback(nil);
    }];
}

- (void)queryAllExperienceInfo:(void (^)(NSArray *experiences))callback
{
    NSString *URLString = [[DDAPIGenerate sharedInstance] API:@"common_experience"];
    
    NSMutableDictionary *params = [@{} mutableCopy];
    
    DDNetWorkManager *manager = [DDNetWorkManager shareManager];
    
    [manager GET:URLString parameters:params success:^(id responseObject) {
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 1) {
            NSArray *datas = responseObject[@"data"];
            NSArray *models = [NSArray yy_modelArrayWithClass:[DDCommonDataModel class] json:datas];
            callback(models);
        }
        else {
            callback(nil);
        }
    } failure:^(id responseObject, NSError *error) {
        callback(nil);
    }];
}

- (void)queryAllEduInfo:(void (^)(NSArray *edus))callback
{
    NSString *URLString = [[DDAPIGenerate sharedInstance] API:@"common_edu"];
    
    NSMutableDictionary *params = [@{} mutableCopy];
    
    DDNetWorkManager *manager = [DDNetWorkManager shareManager];
    
    [manager GET:URLString parameters:params success:^(id responseObject) {
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 1) {
            NSArray *datas = responseObject[@"data"];
            NSArray *models = [NSArray yy_modelArrayWithClass:[DDCommonDataModel class] json:datas];
            callback(models);
        }
        else {
            callback(nil);
        }
    } failure:^(id responseObject, NSError *error) {
        callback(nil);
    }];
}

- (void)queryAllCompanySize:(void (^)(NSArray *companysizes))callback
{
    NSString *URLString = [[DDAPIGenerate sharedInstance] API:@"common_companysize"];
    
    NSMutableDictionary *params = [@{} mutableCopy];
    
    DDNetWorkManager *manager = [DDNetWorkManager shareManager];
    
    [manager GET:URLString parameters:params success:^(id responseObject) {
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 1) {
            NSArray *datas = responseObject[@"data"];
            NSArray *models = [NSArray yy_modelArrayWithClass:[DDCommonDataModel class] json:datas];
            callback(models);
        }
        else {
            callback(nil);
        }
    } failure:^(id responseObject, NSError *error) {
        callback(nil);
    }];
}

- (void)queryAllComplaintsForBoss:(void (^)(NSArray *complaints))callback
{
    NSString *URLString = [[DDAPIGenerate sharedInstance] API:@"query_complaints_about_employer"];
    
    NSMutableDictionary *params = [@{} mutableCopy];
    
    DDNetWorkManager *manager = [DDNetWorkManager shareManager];
    
    [manager GET:URLString parameters:params success:^(id responseObject) {
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 1) {
            NSArray *datas = responseObject[@"data"];
            NSArray *models = [NSArray yy_modelArrayWithClass:[DDCommonDataModel class] json:datas];
            callback(models);
        }
        else {
            callback(nil);
        }
    } failure:^(id responseObject, NSError *error) {
        callback(nil);
    }];
}

- (void)queryAllComplaintsForCattle:(void (^)(NSArray *complaints))callback
{
    NSString *URLString = [[DDAPIGenerate sharedInstance] API:@"query_complaints_about_jobfinder"];
    
    NSMutableDictionary *params = [@{} mutableCopy];
    
    DDNetWorkManager *manager = [DDNetWorkManager shareManager];
    
    [manager GET:URLString parameters:params success:^(id responseObject) {
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 1) {
            NSArray *datas = responseObject[@"data"];
            NSArray *models = [NSArray yy_modelArrayWithClass:[DDCommonDataModel class] json:datas];
            callback(models);
        }
        else {
            callback(nil);
        }
    } failure:^(id responseObject, NSError *error) {
        callback(nil);
    }];
}

- (void)queryAllExperienceSuccessBlock:(successBlock)successBlock
                             failBlock:(faileBlock)failBlock
{
    NSString *URLString = [[DDAPIGenerate sharedInstance] API:@"common_experience"];
    
    NSMutableDictionary *params = [@{} mutableCopy];
    
    DDNetWorkManager *manager = [DDNetWorkManager shareManager];
    
    [manager GET:URLString parameters:params success:successBlock failure:failBlock];
}

@end
